package snake;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.util.List;

public class MyCanvas extends Canvas {

	private Rectangle rect;
	
	private List<Rectangle> snake;

	/**
	 * 
	 */
	private static final long serialVersionUID = -3892192023819204567L;

	@Override
	public void paint(Graphics g) {
		super.paint(g);
		
		//画一个方块
		g.setColor(Color.GREEN);
		if(this.rect != null) {
			g.fill3DRect(rect.x, rect.y, rect.width, rect.height,true);
		}
		
		g.setColor(Color.BLUE);
		if(snake != null) {
			for(Rectangle r : snake) {
				g.fill3DRect(r.x, r.y, r.width, r.height,true);
			}
		}
	}

	public Rectangle getRect() {
		return rect;
	}

	public void setRect(Rectangle rect) {
		this.rect = rect;
	}

	public List<Rectangle> getSnake() {
		return snake;
	}

	public void setSnake(List<Rectangle> snake) {
		this.snake = snake;
	}
	
	
}
